#!/bin/bash

config(){
      alive_sec=120
      our_said=23
      peer_said=120
      local_addr="22.23.25.109"
      peer_addr="22.23.25.110"
      peer_port=4009
      local_port=12123
      server=0
      subnets=20.20.20.6
      network=32
      pc_numble=1
      numble=5  #生成隧道数
     

}

sangforvpn_fenzhi(){
    
        echo dp-debug addtun  \'{"alive_sec":$alive_sec,"our_said":${our_said},"peer_said":${peer_said},"local_addr":"${local_addr}","peer_addr":"$peer_addr","peer_port":$peer_poot,"local_port":$local_port,"server":$server,"subnets":["$subnets/$network"]}\' 
   

}
sangforvpn_zongbu(){


        echo dp-debug addtun  \'{"alive_sec":$alive_sec,"our_said":${peer_said},"peer_said":${our_said},"local_addr":"${peer_addr}","peer_addr":"$local_addr","peer_port":$local_poot,"local_port":$peer_port,"server":$server,"subnets":["$subnets/$network"]}\' 

}
generate(){
    ip=$1
    n=$2
    one_ip=echo $ip|awk -F "." '{print $1}'
    two_ip=echo $ip|awk -F "." '{print $2}'
    three_ip=echo $ip|awk -F "." '{print $3}'
    last_ip=echo $ip|awk -F "." '{print $NF}'

    if [last_ip -gt 255]
    then
         three_ip=`expr $three_ip + 1`
         last_ip=1
         if [three_ip -gt 255]
         then
              two_ip=`expr $two_ip + 1`
         fi

    fi
    last_ip=`expr $last_ip + 1`
    generate_ip=`echo $one_ip.$two_ip.$three_ip.$last_ip`
    return $generate_ip

}

main(){
     config
     i=0
     while [ $i -lt $numble ]
     do  

          
          sangforvpn_fenzhi
          peer_addr=generate($peer_addr)  
          
          peer_said=`expr $peer_said + 1`
          our_said=`expr $our_said + 1`
          i=`expr $i + 1`
     done
}

main $@

